﻿using FXSStation.Modules.SharedInfrastructureModule.BusinessClasses.Users;
using FXSStation.Modules.SharedInfrastructureModule.BusinessClasses.Orders;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System;

namespace FXSStation.Modules.SharedInfrastructureModule.BusinessClasses.Accounts
{
    [Serializable]
    public class Account : INotifyPropertyChanged
    {
        #region Fields

        private string _name;
        private string _description;
        private Balance _balance;
        private Session _currentSession;
        private ObservableCollection<Session> _sessions;
        #endregion // Fields

        #region Properties

        public string Name
        {
            get { return _name; }
            set {
                if (_name != value)
                {
                    _name = value;
                    RaisePropertyChanged("Name");
                }
            }
        }
        public string Description
        {
            get { return _description; }
            set
            {
                if (_description != value)
                {
                    _description = value;
                    RaisePropertyChanged("Description");
                }
            }
        }
        public Balance Balance
        {
            get { return _balance; }
            set {
                if (_balance != value)
                {
                    _balance = value;
                    RaisePropertyChanged("Balance");
                }
            }
        }
        public Session CurrentSession
        {
            get { return _currentSession; }
            set
            {
                if (_currentSession != value)
                {
                    _currentSession = value;
                    RaisePropertyChanged("CurrentSession");
                }
            }
        }
        public ObservableCollection<Session> Sessions
        {
            get { return _sessions; }
            set
            {
                if (_sessions != value)
                {
                    _sessions = value;
                }
            }
        }

        #endregion // Properties

        #region Constructors

        public Account(string name, Balance ballance)
        {
            this._name = name;
            this._balance = ballance;
            this._sessions = new ObservableCollection<Session>();
        }

        public Account(string name, Balance ballance, string description)
        {
            this._name = name;
            this._balance = ballance;
            this._description = description;
            this._sessions = new ObservableCollection<Session>();
        }

        #endregion // Constructors

        #region INotifyPropertyChanged Members
        [field:NonSerialized]
        public event PropertyChangedEventHandler PropertyChanged;

        public void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }


        #endregion
    }
}
